package com.itheima.service.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.OperateLogMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.pojo.*;
import com.itheima.service.ReportService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Resource
    private EmpMapper empMapper;
    @Resource
    private StudentMapper studentMapper;
    @Resource
    private OperateLogMapper operateLogMapper;
    /**
     * 员工职位人数统计
     */
    @Override
    public EmpJobReportData empJobData() {
        List<EmpJob> empJobs = empMapper.empJobData();
        List<String> collect = empJobs.stream().map(empJob -> empJob.getJob()).collect(Collectors.toList());
        List<Integer> collect1 = empJobs.stream().map(empJob -> empJob.getCot()).collect(Collectors.toList());

        return new EmpJobReportData(collect,collect1);
    }

    /**
     * 员工性别统计
     */
    @Override
    public List<EmpGender> empGender() {
        List<EmpGender> empGenders = empMapper.empGender();
        return empGenders;
    }

    /**
     * 班级人数统计
     */
    @Override
    public ClazzReportData StuClazz() {
        List<StuClazz> stuClazzes = studentMapper.stuClazz();
        List<String> collect = stuClazzes.stream().map(stuClazz -> stuClazz.getClazzName()).collect(Collectors.toList());
        List<Integer> collect1 = stuClazzes.stream().map(stuClazz -> stuClazz.getCnt()).collect(Collectors.toList());

        return new ClazzReportData(collect,collect1);
    }

    /**
     * 学员学历统计
     */
    @Override
    public List<EmpGender> stuDegree() {
        List<EmpGender> lists = studentMapper.stuDegree();
        return lists;
    }




}
